<!DOCTYPE html>
<html>
<head>
    <title>server_1</title>
</head>
<body>
    <h1>服务端跨域访问1：JSONP 跨域请求示例</h1>
    <h2>
        当前路径：<span id="cururl"></span>
    </h2>
    <div id="result"></div>
    
    <script>
        document.getElementById('cururl').innerHTML = window.location.href;
        
        // 定义回调函数
        function printResponse(data) {
            document.getElementById('result').textContent = 
                '数据: ' + JSON.stringify(data);
        }

        // 创建script标签发起JSONP请求
        function loadData() {
            const script = document.createElement('script');
            script.src = 'http://sub.websecurity.com/jsonp/data?callback=printResponse';
            document.body.appendChild(script);
        }

        loadData();
    </script>
</body>
</html>